<template>
  <div class="w jcc">
    <div class="img">
      <div><img src="@/assets/images/404.png" alt></div>
      <div>{{msg}}</div>
      <div class="btn m-c shou" @click="click" v-if="code != 900">返回首页</div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import {
    useRouter
  } from 'vue-router'
  import {
    inject,
    ref
  } from 'vue'
  const router = useRouter()
  const errorObj = inject('errorObj')
  const code = ref('')
  const msg = ref('')
  if (errorObj && errorObj.value) {
    code.value = errorObj.value.code
    msg.value = errorObj.value.msg || '哦噢，页面找不到了吧'
  }
  const click = () => {
    router.push('/')
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .img {
    transform: translateY(50%);
    text-align: center;

    img {
      width: 600px;
    }
  }

  .btn {
    display: inline-block;
    font-size: 18px;
    padding: 10px;
    color: white;
    border-radius: 10px;
    width: fit-content;
    background-color: rgb(113, 166, 209);
  }
</style>
